import { request } from '@/http/request/alova'
const domain = import.meta.env.VITE_IM_API_URL
export function getUserTerminalOnlineInfo(params: {userIds: string}) {
  return request.Get(`/im/user/terminal/online`, { params, meta: {domain}})
}
export const getFriendList = () => {
  return request.Get('/im/friend/list', {meta: {domain}})
}
export const pullOfflineMessage = (params: Record<string,any>) => {
  return request.Get('/im/message/private/pullOfflineMessage', {params, meta: {domain}})
}
export const findFriendById = (friendId: string) => {
  return request.Get(`/im/friend/find/${friendId}`, {meta: {domain}})
}
export const getPrivateMaxReadedId = (params:{friendId: string}) => {
  return request.Get(`/im/message/private/maxReadedId`, {params, meta: {domain}})
}
export const setPrivateChatReaded = (data:{friendId: string}) => {
  return request.Put(`/im/message/private/readed`,data, {params: data, meta: {domain}})
}

export const sendMessage = (data:{recvId: string, content: string, type: string|number}) => {
  return request.Post(`/im/message/private/send`,data, {meta: {domain}})
}
export const deleteFriend = (friendId: string) => {
  return request.Delete(`/im/friend/delete/${friendId}`, {friendId}, {meta: {domain}})
}
export const getUserById = (id: string) => {
  return request.Get(`/im/user/find/${id}`, {meta: {domain}})
}
// export const getSelfInfo = () => {
//   return request.Get(`/im/user/self`, {meta: {domain}})
// }
export const addFriend = (params:{friendId: string}) => {
  return request.Post('/im/friend/add', params, {params, meta: {domain}})
}
export const findUserByName = (params:{name: string}) => {
  return request.Get('/im/user/findByName', {params, meta: {domain}})
}
export const findFriendOrAddById = (params: {friendId: string}) => {
  return request.Get(`/im/friend/findWithAddFriend`, {params, meta: {domain, original: true}})
}